package models;

import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;

import play.db.jpa.Model;

@Entity

public class Class extends Model {
	
	public static final byte NOT_ENTERED = 1;
	public static final byte ATTENDED = 2;
	public static final byte ABSCENT = 3;
	public static final byte EXCUSED = 4;
	
	
	public Date datetime;
	
	@ManyToOne
	public Register registration;
	
	public byte student_attendance;
	public byte teacher_attendance;
	
	public boolean isTrial;
	public boolean isCancelled;
	
	public Class(Date datetime, Register registration) {
		
		this.datetime = datetime;
		this.registration = registration;
		this.isTrial = false;
		student_attendance = this.NOT_ENTERED;
		teacher_attendance = this.NOT_ENTERED;
	}

	public void studentAttendance(Byte a) {
		
		this.student_attendance = a;
		registration.resetClassesToBeCompensated();
		
		
	}
	
	public void teacherAttendance(Byte a) {
		
		
		this.teacher_attendance = a;
		registration.resetClassesToBeCompensated();
		
		
	}
	
	public String decodeA(byte a) {
		
		switch(a) {
		case 1: return "Not entered";
		case 2: return "Attended";
		case 3: return "Absent";
		default: return "Excused";	
		
		}
		
	}
	
	
	

}
